<template>
	<view class="container">
		<view class="evaluation-item" @click="navigateToOrderDetails">
			<view class="user-info">
				<text class="user-name">{{ evaluation.userName }} </text>
				<text class="evaluation-time">评价时间：{{ evaluation.evaluationTime }}</text>
				<text class="order-id" @click="navigateToOrderDetails">{{ evaluation.orderId }}</text>
			</view>
			<view class="rating">
				<text class="rating-label">综合评分：{{ evaluation.rating }}分</text>
				<view class="stars">
					<uni-icons type="star" size="24" color="#ffcc00" v-for="filled in filledStars"
						:key="filled"></uni-icons>
					<uni-icons type="star" size="24" color="#cccccc" v-for="empty in emptyStars"
						:key="empty"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		computed
	} from "vue";
	import uniIcons from "@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue";

	const evaluation = ref({
		userName: "张**",
		evaluationTime: "2022-10-10 11:09",
		orderId: "2021010831213",
		rating: 3,
	});

	const filledStars = computed(() => {
		return Array.from({
			length: evaluation.value.rating
		}, (_, index) => index);
	});

	const emptyStars = computed(() => {
		return Array.from({
			length: 5 - evaluation.value.rating
		}, (_, index) => index);
	});

	const navigateToOrderDetails = () => {
		// uni.showToast({
		// 	title: `查看订单详情：${evaluation.value.orderId}`,
		// 	icon: "success",
		// });
		uni.navigateTo({
			url: "/pages/index/evaluationManagement/details/details",
		});
	};
</script>

<style scoped>
	.container {
		padding: 10rpx;
		background-color: white;
	}

	.evaluation-item {
		background-color: #ffffff;
		padding: 20rpx;
		padding-bottom: 40rpx;
		margin-bottom: 20rpx;
		border-bottom: 2rpx solid rgba(0, 0, 0, 0.2);
	}

	.user-info {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.user-name {
		font-size: 32rpx;
		color: black;
		font-weight: bold;

	}

	.evaluation-time {
		font-size: 26rpx;
		color: #999999;
	}

	.order-id {
		font-size: 26rpx;
		color: blue;
		text-decoration: underline;
		font-weight: bold;
		cursor: pointer;
	}

	.rating {
		display: flex;
		align-items: center;
		color: black;
	}

	.rating-label {
		font-size: 30rpx;
		color: #333;
		margin-right: 20rpx;
		font-weight: 700;
	}

	.stars {
		display: flex;
	}
</style>